<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
     Yolin
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.png" />
  
  
<link rel="stylesheet" href="/css/style.css">

  
<script src="/js/pace.min.js"></script>


  

  

<link rel="alternate" href="/atom.xml" title="Yolin" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover2.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">Yolin</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js"></script>

<div id="main">
  <section class="outer">
  <article class="articles">
    
    
    
    
    <article id="post-定制Hadoop启动脚本" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/26/%E5%AE%9A%E5%88%B6Hadoop%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC/"
    >定制Hadoop启动脚本</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/26/%E5%AE%9A%E5%88%B6Hadoop%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC/" class="article-date">
  <time datetime="2020-03-26T06:46:02.000Z" itemprop="datePublished">2020-03-26</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Linux/">Linux</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="目的"><a href="#目的" class="headerlink" title="目的"></a>目的</h2><blockquote>
<p>将命令行的命令（启动的四条命令和关闭的四条命令）写在单独的脚本文件中，实现简单的执行脚本文件达到自动执行命令。</p>
</blockquote>
<h2 id="一、创建脚本文件"><a href="#一、创建脚本文件" class="headerlink" title="一、创建脚本文件"></a>一、创建脚本文件</h2><p>在hadoop安装目录下使用命令</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">touch hadoop-start.sh</span><br><span class="line">touch hadoop-end.sh</span><br></pre></td></tr></table></figure>
<h2 id="二、写入命令"><a href="#二、写入命令" class="headerlink" title="二、写入命令"></a>二、写入命令</h2><p>分别打开两个脚本文件写入如下命令：</p>
<p><a href="#"><strong>hadoop-start.sh</strong></a></p>
      
      <a class="article-more-link" href="/2020/03/26/%E5%AE%9A%E5%88%B6Hadoop%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Hadoop/" rel="tag">Hadoop</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/chmod/" rel="tag">chmod</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%84%9A%E6%9C%AC/" rel="tag">脚本</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-HTTP与web" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/21/HTTP%E4%B8%8Eweb/"
    >HTTP与Web</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/21/HTTP%E4%B8%8Eweb/" class="article-date">
  <time datetime="2020-03-21T09:46:02.000Z" itemprop="datePublished">2020-03-21</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/">计算机网络</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="序论"><a href="#序论" class="headerlink" title="序论"></a>序论</h2><p>你是否好奇当我们访问网页时，浏览器是如何识别我们输入的网址并将我们想要的内容呈现出来的吗？<br><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/yolin/032101.png" alt=""></p>
<p>当我们在地址栏输入<a href="#">URL</a>(网址)，浏览器会向<a href="#">DNS</a>(域名服务器)提供网址，结合域名服务器来完成URL到IP地址的映射。然后将请求提交给具体服务器（发送<a href="#">http请求</a>），再由服务器返回我们要的结果(html编码格式)，浏览器执行HTML编码，将内容呈现给我们。</p>
      
      <a class="article-more-link" href="/2020/03/21/HTTP%E4%B8%8Eweb/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/HTTP/" rel="tag">HTTP</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Web/" rel="tag">Web</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Git的使用-二" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/18/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%BA%8C/"
    >Git的使用(二)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/18/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%BA%8C/" class="article-date">
  <time datetime="2020-03-18T12:46:02.000Z" itemprop="datePublished">2020-03-18</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Git/">Git</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <blockquote>
<h1 id="再次创建新的版本"><a href="#再次创建新的版本" class="headerlink" title="再次创建新的版本"></a>再次创建新的版本</h1></blockquote>
<p>接着上一节我们继续修改<a href=""><strong>hellogit.txt</strong></a>文件内容：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Git is a distributed version control system.</span><br><span class="line">Git is free software distributed under the GPL.</span><br></pre></td></tr></table></figure>

<p>提交到仓库并添加描述</p>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/yolin/031801.png" alt=""></p>
<blockquote>
<h1 id="git-log"><a href="#git-log" class="headerlink" title="git log"></a>git log</h1></blockquote>
<h4 id="git-log-可以让我们查看提交历史"><a href="#git-log-可以让我们查看提交历史" class="headerlink" title="git log 可以让我们查看提交历史"></a>git log 可以让我们查看提交历史</h4>
      
      <a class="article-more-link" href="/2020/03/18/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%BA%8C/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git%E7%89%88%E6%9C%AC%E5%9B%9E%E9%80%80/" rel="tag">git版本回退</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Git的使用-一" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/12/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%B8%80/"
    >Git的使用(一)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/12/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%B8%80/" class="article-date">
  <time datetime="2020-03-12T14:46:02.000Z" itemprop="datePublished">2020-03-12</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Git/">Git</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h3 id="创建版本库"><a href="#创建版本库" class="headerlink" title="创建版本库"></a>创建版本库</h3><p>在任意位置右键打开Git命令，这里我是在桌面</p>
<p>执行以下命令</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir yolin  <span class="comment">//文件名最好不要中文，不然会及其麻烦</span></span><br><span class="line">cd yolin   <span class="comment">//切换目录</span></span><br><span class="line">pwd   <span class="comment">//查看当前目录</span></span><br></pre></td></tr></table></figure>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/web_img/031201.png" alt=""></p>
<h3 id="git-init命令把这个目录变成Git可以管理的仓库"><a href="#git-init命令把这个目录变成Git可以管理的仓库" class="headerlink" title="git init命令把这个目录变成Git可以管理的仓库"></a>git init命令把这个目录变成Git可以管理的仓库</h3>
      
      <a class="article-more-link" href="/2020/03/12/Git%E7%9A%84%E4%BD%BF%E7%94%A8-%E4%B8%80/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git%E7%89%88%E6%9C%AC%E5%BA%93/" rel="tag">git版本库</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-版本控制软件" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/12/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E8%BD%AF%E4%BB%B6/"
    >为何要使用版本控制软件？</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/12/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E8%BD%AF%E4%BB%B6/" class="article-date">
  <time datetime="2020-03-12T13:46:02.000Z" itemprop="datePublished">2020-03-12</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Git/">Git</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><blockquote>
<p>在项目开发过程中，一个永久性能的话题就是对代码的管理问题</p>
</blockquote>
<p>你想在你项目基础上增加新的功能，又担心某些复杂的问题会影响到其他部分的内容，此时你肯定会去备份源代码，而改好了后，备份的代码何去何从又成了问题，</p>
<p>删了？</p>
<p>害怕万一哪天测试崩溃了又想回到之前的状态</p>
<p>不删？</p>
<p>那每写一次都需要备份一下，越来越多的小差异文件势必会对代码维护造成影响</p>
<p>又例如当你把任务分工给别人去完成的时候，最终代码合并又会面临各种需求。</p>
<p><strong>因而你会不断发现新的需求，不断发现问题,如果不做控制，你的代码早晚会崩溃掉</strong></p>
      
      <a class="article-more-link" href="/2020/03/12/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E8%BD%AF%E4%BB%B6/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Git/" rel="tag">Git</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SVN/" rel="tag">SVN</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/github/" rel="tag">github</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Xshell6连接到虚拟机" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/12/Xshell6%E8%BF%9E%E6%8E%A5%E5%88%B0%E8%99%9A%E6%8B%9F%E6%9C%BA/"
    >Xshell6连接到虚拟机</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/12/Xshell6%E8%BF%9E%E6%8E%A5%E5%88%B0%E8%99%9A%E6%8B%9F%E6%9C%BA/" class="article-date">
  <time datetime="2020-03-12T02:46:02.000Z" itemprop="datePublished">2020-03-12</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Linux/">Linux</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="一、查看IP地址"><a href="#一、查看IP地址" class="headerlink" title="一、查看IP地址"></a>一、查看IP地址</h1><h3 id="ip-addr"><a href="#ip-addr" class="headerlink" title="ip addr"></a>ip addr</h3><p>Centos7中,要查看IP地址,不再使用ifconfig命令,而是使用了<a href="">ip addr</a>命令。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ip addr</span><br></pre></td></tr></table></figure>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/yolin/03120.png" alt="addr"></p>
<h3 id="详解"><a href="#详解" class="headerlink" title="详解"></a>详解</h3><ul>
<li><strong>lo</strong>：全称loopback，是回环地址，经常被分配到127.0.0.1地址上，用于本机通信，经过内核处理后直接返回，不会在任何网络中出现。</li>
<li><strong>link/loopback</strong>：这个是MAC地址，唯一的，一块网卡一个MAC。</li>
<li><strong>inet</strong>：网卡上绑定的IP地址</li>
<li><strong>inet6</strong>：IPV6地址，暂时没有，预留。</li>
<li><strong>ens33</strong>：网卡名，如果有多块网卡，会有多个ens或其它名称。    </li>
<li><strong>网络设备状态标识</strong>：&lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt;</li>
<li><strong>carrier</strong>：也就是载波，它的值越低越好。通常是物理层造成的，比如电缆问题、强电干扰等</li>
<li><strong>UP</strong>：网卡处于启动状态。
      
      <a class="article-more-link" href="/2020/03/12/Xshell6%E8%BF%9E%E6%8E%A5%E5%88%B0%E8%99%9A%E6%8B%9F%E6%9C%BA/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Centos7/" rel="tag">Centos7</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/IP/" rel="tag">IP</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/" rel="tag">虚拟机</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-git分支初体验" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/07/git%E5%88%86%E6%94%AF%E5%88%9D%E4%BD%93%E9%AA%8C/"
    >git分支初体验</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/07/git%E5%88%86%E6%94%AF%E5%88%9D%E4%BD%93%E9%AA%8C/" class="article-date">
  <time datetime="2020-03-07T13:29:02.000Z" itemprop="datePublished">2020-03-07</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Git/">Git</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="简述"><a href="#简述" class="headerlink" title="简述"></a>简述</h1><p>就一般项目开发而言，我们会自己创建一个分支，经过测试正常后会把这个分支合并到主分支上，这样可以提高开发效率，保证代码质量，可以更快定位到bug</p>
<h1 id="栗子"><a href="#栗子" class="headerlink" title="栗子"></a>栗子</h1><h4 id="在码云上创建了分支"><a href="#在码云上创建了分支" class="headerlink" title="在码云上创建了分支"></a>在码云上创建了分支</h4><p>（例如index-icons）</p>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/web_img/376.png?x-oss-process=image/resize,m_fill,h_180,w_150" alt=""></p>
<h4 id="把线上的分支拉到本地"><a href="#把线上的分支拉到本地" class="headerlink" title="把线上的分支拉到本地"></a>把线上的分支拉到本地</h4>
      
      <a class="article-more-link" href="/2020/03/07/git%E5%88%86%E6%94%AF%E5%88%9D%E4%BD%93%E9%AA%8C/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Vue/" rel="tag">Vue</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Vue中使用axios发送ajax请求" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/03/07/Vue%E4%B8%AD%E4%BD%BF%E7%94%A8axios%E5%8F%91%E9%80%81ajax%E8%AF%B7%E6%B1%82/"
    >Vue中使用axios发送ajax请求</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/07/Vue%E4%B8%AD%E4%BD%BF%E7%94%A8axios%E5%8F%91%E9%80%81ajax%E8%AF%B7%E6%B1%82/" class="article-date">
  <time datetime="2020-03-07T12:12:02.000Z" itemprop="datePublished">2020-03-07</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Vue/">Vue</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h1><p>在Vue中发送Ajax有很多工具可以实现，例如：</p>
<ul>
<li>浏览器自带的<strong>fetch函数</strong></li>
<li><strong>vue-resource</strong>第三方模块</li>
<li><strong>axios</strong>(vue推荐使用的模块)</li>
</ul>
<h1 id="Axios简介"><a href="#Axios简介" class="headerlink" title="Axios简介"></a>Axios简介</h1><p>Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。</p>
<h4 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h4>
      
      <a class="article-more-link" href="/2020/03/07/Vue%E4%B8%AD%E4%BD%BF%E7%94%A8axios%E5%8F%91%E9%80%81ajax%E8%AF%B7%E6%B1%82/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Vue/" rel="tag">Vue</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-普通函数与箭头函数" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/02/22/%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E4%B8%8E%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0/"
    >普通函数与箭头函数this指向问题</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/02/22/%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E4%B8%8E%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0/" class="article-date">
  <time datetime="2020-02-22T10:56:02.000Z" itemprop="datePublished">2020-02-22</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/JavaScript/">JavaScript</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、普通函数"><a href="#一、普通函数" class="headerlink" title="一、普通函数"></a>一、普通函数</h2><h3 id="举例"><a href="#举例" class="headerlink" title="举例"></a>举例</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a=<span class="number">5</span>;  <span class="comment">//全局变量</span></span><br><span class="line"><span class="keyword">var</span> obj=&#123;</span><br><span class="line">    a:<span class="number">2</span>,</span><br><span class="line">    show:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="keyword">this</span>.a);</span><br><span class="line">      &#125;   </span><br><span class="line">&#125;</span><br><span class="line">obj.show();   <span class="comment">//2</span></span><br><span class="line"><span class="keyword">var</span> obj2=obj;</span><br><span class="line">obj2.a=<span class="number">8</span>;</span><br><span class="line">obj2.show();    <span class="comment">//8</span></span><br><span class="line"><span class="keyword">var</span> obj3=obj.show;</span><br><span class="line">obj3();      <span class="comment">//5</span></span><br></pre></td></tr></table></figure>
<h3 id="发现"><a href="#发现" class="headerlink" title="发现"></a>发现</h3><p>三次调用show方法，我们可以发现：</p>
<ul>
<li><strong>当直接调用对象自己内的方法时，this指向调用show方法的对象即obj；</strong></li>
<li><strong>而将obj赋给新对象obj2时，再调用show时this就指向调用者obj2</strong>；
      
      <a class="article-more-link" href="/2020/02/22/%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E4%B8%8E%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/" rel="tag">JavaScript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/this/" rel="tag">this</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0/" rel="tag">普通函数</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0/" rel="tag">箭头函数</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-网红面试题" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/02/20/%E7%BD%91%E7%BA%A2%E9%9D%A2%E8%AF%95%E9%A2%98/"
    >网红面试题[&#39;1&#39;,&#39;2&#39;,&#39;3&#39;].map(parseInt)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/02/20/%E7%BD%91%E7%BA%A2%E9%9D%A2%E8%AF%95%E9%A2%98/" class="article-date">
  <time datetime="2020-02-20T07:53:02.000Z" itemprop="datePublished">2020-02-20</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/JavaScript/">JavaScript</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>作为一道大厂考过的题，有必要在这里探讨一番，首先测试一下结果：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a=<span class="keyword">new</span> <span class="built_in">String</span>;</span><br><span class="line">a=[<span class="string">'1'</span>,<span class="string">'2'</span>,<span class="string">'3'</span>].map(<span class="built_in">parseInt</span>);</span><br><span class="line"><span class="built_in">console</span>.log(a);</span><br></pre></td></tr></table></figure>
<p>结果返回数组[1,NaN,NaN]</p>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/web_img/201.png?x-oss-process=image/resize,m_fill,h_150,w_180" alt=""></p>
<p>parseInt将字符串转换成整形，map再将所有整形数据存在数组里，<br>不应该是[1,2,3]的么，NaN是什么鬼？</p>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/web_img/206.jpg?x-oss-process=image/resize,m_fill,h_160,w_170" alt=""></p>
      
      <a class="article-more-link" href="/2020/02/20/%E7%BD%91%E7%BA%A2%E9%9D%A2%E8%AF%95%E9%A2%98/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/" rel="tag">JavaScript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/map/" rel="tag">map()</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/parseInt/" rel="tag">parseInt()</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/8/">上一页</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="page-number" href="/page/8/">8</a><span class="page-number current">9</span><a class="page-number" href="/page/10/">10</a><a class="extend next" rel="next" href="/page/10/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        张金
      </li>
      <li>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
        <img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/beian.png">
        <a href="https://beian.miit.gov.cn"  style="color:#f72b07" target="_blank">陕ICP备20002449号</a>
      </li>

    </ul>
  </div>
</footer>
    <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
      <aside class="sidebar">
        <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Yolin"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/playlist">歌单</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/video">视频</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友情链接</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
      </aside>
      <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
      
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<script src="/js/share.js"></script>




<script>
  try {
    var typed = new Typed("#subtitle", {
    strings: ['肠断月明红豆蔻,','月似当时,','人似当时否？'],
    startDelay: 1500,
    typeSpeed: 200,
    loop: true,
    backSpeed: 40,
    showCursor: true
    });
  } catch (err) {
  }
  
</script>




<script>
  var ayerConfig = {
    mathjax: true
  }
</script>


<script src="/js/ayer.js"></script>


<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>



<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
  </div>
</body>

</html>